package sg4c.frontend.command;

import java.io.IOException;
import sg4c.frontend.GraphicsContext;
import sg4c.protocol.DataInputProtocol;

public class Translate implements GraphicsCommand {

    private final int x;
    private final int y;

    public Translate(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public void execute(GraphicsContext context) {
        context.getGraphics().translate(x, y);
    }

    public static final Factory factory = new Factory() {

        public GraphicsCommand parse(DataInputProtocol in) throws IOException {
            int x = in.readInt();
            int y = in.readInt();
            return new Translate(x, y);
        }
    };
}
